import Vue from 'vue'
import Router from 'vue-router'
import '@/assets/css/reset.css'
import '@/assets/css/header.css'


Vue.use(Router)

import Shop from '@/views/shop'
import Index from '@/views/index'
import Item from '@/views/item'
import Cart from '@/views/cart'
import Checkout from '@/views/checkout'
import Payment from '@/views/payment'
import Account from '@/views/account'
import Order from '@/views/account/order'
import Address from '@/views/account/address'
import PhoneDispaly from '@/views/phone-dispaly'
import ShopHot from '@/views/shop-hot'
import MiPhone from '@/views/phone/mi-phone'
import HuaweiPhone from '@/views/phone/huawei-phone'
import JianguoPhone from '@/views/phone/jianguo-phone'
import Login from '@/views/login/login'
import Register from '@/views/login/register'
import ForgotenPassword from '@/views/login/forgotenpassword'
import ResetPassword from '@/views/login/resetpassword'
import Manage from '@/views/admin/manage'
import Admin from '@/views/admin/admin'
import Home from '@/views/admin/home'
import AddGoods from '@/views/admin/addGoods'
import AdminList from '@/views/admin/adminList'
import OrderList from '@/views/admin/orderList'
import UserList from '@/views/admin/userList'
import Explain from '@/views/admin/explain'
import HuaWeiP30 from '@/views/phone/huawei-p30'
import Mi9Phone from '@/views/phone/mi9-phone'
import ApplePhone from '@/views/phone/apple-phone'


export default new Router({
  mode: 'history',
  scrollBehavior (to, from, savePosition) {
    if (savePosition) {
      return savePosition
    } else {
      return {x: 0, y: 0}
    }
  },
  routes: [
    {
      path: '/',
      name: 'index',
      component: Index,
      meta: {
        needLogin: false
      }
    },
    {
      path: '/huawei-p30',
      name: 'HuaWeiP30',
      component: HuaWeiP30
    },
    {
      path: '/mi9-phone',
      name: 'Mi9Phone',
      component: Mi9Phone
    },
    {
      path:  '/apple-phone',
      name: 'ApplePhone',
      component: ApplePhone
    },
    {
      name: 'Login',
      path: '/login',
      component: Login,
      meta: {
        isLogin: false
      }
  },
    {
      path: '/register',
      name: 'Register',
      component: Register
    },
    {
      path: '/forgotenpassword',
      name: 'ForgotenPassword',
      component: ForgotenPassword
    },
    {
      path: '/resetpassword',
      name: 'ResetPassword',
      component: ResetPassword
    },
    {
      path: '/manage',
      name: 'Manage',
      component: Manage,
      children: [{
        path: '',
        component: Home,
        meta: [],
      },
        {
        path: '/addGoods',
        component: AddGoods,
        meta: ['添加数据', '添加商品'],
      },
        {
        path: '/userList',
        component: UserList,
        meta: ['数据管理', '用户列表'],
      },
        {
        path: '/orderList',
        component: OrderList,
        meta: ['数据管理', '订单列表'],
      },{
        path: '/adminList',
        component: AdminList,
        meta: ['数据管理', '管理员列表'],
      },
        {
        path: '/explain',
        component: Explain,
        meta: ['说明', '说明'],
      }]
    },
    {
      path: '/admin',
      name:  'Admin',
      component: Admin
    },
    {
      path: '/shop',
      name: 'shop',
      component: Shop,
      meta: {
        isLogin: false
      }
    },
    {
      path: '/item',
      name: 'Item',
      component: Item,
      meta: {
        isLogin: false
      }
    },
    {
      path: '/cart',
      name: 'Cart',
      component: Cart,
      meta: {
        requireLogin: true
      }
    },
    {
      path: '/checkout',
      name: 'Checkout',
      component: Checkout,
      meta: {
        requireLogin: true
      }
    },
    {
      path: '/payment',
      name: 'Payment',
      component: Payment,
      meta: {
        requireLogin: true
      }
    },
    {
      path: '/account',
      component: Account,
      meta: {
        requireLogin: true
      },
      children: [
        {
          path: '',
          name: 'Account',
          component: Order
        },
        {
          path: '/address',
          name: 'Address',
          component: Address
        },
        {
          path: '/phone-dispaly',
          name: 'PhoneDispaly',
          component: PhoneDispaly
        },
        {
          path: '/shop-hot',
          name: 'ShopHot',
          component: ShopHot
        },
        {
          path: '/mi-phone',
          name: 'MiPhone',
          component: MiPhone
        },
        {
          path: '/huawei-phone',
          name: 'HuaweiPhone',
          component: HuaweiPhone
        },
        {
          path: '/jianguo-phone',
          name: 'JianguoPhone',
          component: JianguoPhone
        }
      ]
    }
  ]
})
